#include<stdio.h>
#include<stdlib.h>
#include"tree.h"
#define MaxSize 66
int main()
{
    int n=0;
    TSonNode *t;
    array R[MaxSize];
    FILE *fp;
    if((fp=fopen("table.txt","r"))==NULL)    
        {
        printf("error!cannot open the file!");
        exit(1);
        }
    printf("读取文件内容存入数组R中\n");
    ReadFile(R,fp,n);
    printf("输出数组R:\n");
    for(int i=0;i<n;i++)
        printf("%s %s\n",R[i].N,R[i].n); 
    printf("\n由数组R创建树T,");
    t=CreateTree(R[0].N,R,n);   
    printf("由括号表示输出树T:\n");
    DispTree(t);
    char str[10];
    printf("\n请输入学院名:");
    scanf("%s",str);
    printf("\n%s的专业数:%d\n",str,ChildCount(FindNode(t,str)));
    printf("%s的班级数:%d\n",str,LeafCount(FindNode(t,str)));
    printf("\n请输入学院名:");
    scanf("%s",str);
    printf("\n%s的学生数:%d\n",str,LeafSumOfvalue(FindNode(t,str)));
    printf("销毁树!\n");
    DestroyTree(t);
    return 0;
}